﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WRJClient.ViewModel;
using WRJClient.UI.Map;
using Esri.ArcGISRuntime.Geometry;

namespace WRJClient.UI.SystemMonitor
{
    /// <summary>
    /// WorkStationView.xaml 的交互逻辑
    /// </summary>
    public partial class WorkStationView : UserControl
    {
        public WorkStationView(WorkStationViewModel model)
        {
            InitializeComponent();
            MapManager.Instance.Init(baseMap);
            body.DataContext = model;

            model.PropertyChanged += Model_PropertyChanged;

            model.AddGraphics();

        }

        private void Model_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            WorkStationViewModel model = sender as WorkStationViewModel;
            if (model != null && model.StaticData != null)
            {
                MapPoint point = new MapPoint(model.StaticData.Longitude, model.StaticData.Latitude, SpatialReferences.Wgs84);
                baseMap.PanTo(point, 200000);
            }
        }
    }
}
